using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;

namespace wepKeyGen
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach (string key in Gen128(args[0]))
                Console.WriteLine(key);
            foreach (string key in Gen64(args[0]))
                Console.WriteLine(key);
        }

        public static string hexString(byte[] bytes, int limit)
        {
            StringBuilder sb = new StringBuilder(bytes.Length * 2);
            foreach (byte b in bytes)
                sb.Append(b.ToString("X2"));
            return sb.ToString(0, limit);
        }

        public static string wep128_passphrase(string key)
        {
            MD5 md = MD5.Create();
            int len = key.Length;
            byte[] genkey = new byte[64];

            for (int i = 0; i < 64; i++)
                genkey[i] = (byte)key[i % len];
            md.ComputeHash(genkey);
            return hexString(md.Hash, 26);
        }

        static IEnumerable<string> Gen128(string genstr)
        {
            yield return wep128_passphrase(genstr);
            yield return wep128_passphrase(genstr + "#$%");
            yield return wep128_passphrase(genstr + "#$%!@#");
            yield return wep128_passphrase(genstr + "#$%!@#%&^");
        }

        static IEnumerable<string> Gen64(string genstr)
        {
           	byte[] pseed = {0,0,0,0};
            long randNumber = 0;
            int len = genstr.Length;
            for (int i = 0; i < len; i++)
                pseed[i % 4] ^= (byte)genstr[i];
            randNumber = (long)pseed[0] |
                        ((long)pseed[1]) << 8 |
                        ((long)pseed[2]) << 16 |
                        ((long)pseed[3]) << 24;
            for (int i = 0; i < 4; i++)
            {
                byte[] genkey = new byte[5];
                for (int j = 0; j < 5; j++)
                {
                    randNumber *= 0x343fd;
                    randNumber += 0x269ec3;
                    genkey[j] = (byte)((randNumber >> 16) & 0x7fff);
                }
                yield return hexString(genkey, 10);
            }
        }
    }
}
